<template>
  <div id="app">
    <!-- 顶部导航栏 -->
    <nav v-if="user">
      <div v-if="user.role === 'admin'">
        <router-link to="/activity-management">活动管理</router-link> |
      </div>
      <router-link to="/public-activities">公开活动列表</router-link>
    </nav>

    <!-- 路由视图 -->
    <router-view></router-view>
  </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
  name: 'App',
  computed: {
    ...mapState(['user']) // 映射 Vuex 中的 user 状态
  }
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>